/*
** 创建时间：200501
** 文件名：windows.hpp
** 用途：多窗口
*/

#pragma once
#ifndef XEGE_WINDOWS
#define XEGE_WINDOWS

#include "xege.h"

namespace xege {

class WINDOW : /* protected IMAGE_BASE */public PAINT {
protected:
	SDL_Window*   window;
private:
	SDL_Event*    event = new SDL_Event;
	std::string   title;
	std::thread*  winEvent;
	// std::thread 并不支持合成构造函数
	bool isRunFlag;
	std::map <std::string, std::function<void(SDL_EventType)>> events;
	// 
public:
	static bool INITFlag;
	static int id;
	friend class PAINT;
	friend class IMAGE;
	friend class IMAGE_BASE;
	WINDOW (
		int w = 800, int h = 600,
		int x = SDL_WINDOWPOS_UNDEFINED,
		int y = SDL_WINDOWPOS_UNDEFINED, 
		int winMode = SDL_WINDOW_SHOWN,
		int renMode = SDL_RENDERER_ACCELERATED
	);
	WINDOW (WINDOW& window)           = default;
	WINDOW& operator=(const WINDOW& window);
	WINDOW& operator=(WINDOW&& window);
	~WINDOW ();
	operator bool();

	WINDOW& setTitle (std::string title);
	WINDOW& clear ();
	WINDOW& updateTexture (void);
	WINDOW& update (void);
	
	WINDOW& close ();
	WINDOW& show (void);
	WINDOW& hide (void);
	// 置顶
	WINDOW& raise (void);
	bool isRun (void);
	bool resized (void) {
		return false;
	}
	bool isActive (void) {
		return false;
	}
	bool isVisiable (void) {
		return false;
	}
	// 上下两个函数功能一样，不过名字和返回值相反
	bool isHidden (void) {
		return false;
	}
	

	SDL_Window* getpWindow (void);
	SDL_Window& getWindow (void);
};  // 类 WINDOW 结尾


}  // 命名空间 xege 结尾
// xege::WINDOW::INITFlag = false;
// xege::WINDOW::id = 0;
#endif